package cn.xscrum.demo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.xscrum.common.annotation.Log;
import cn.xscrum.common.enums.BusinessType;
import cn.xscrum.demo.domain.FlowPassengerNumber;
import cn.xscrum.demo.service.IFlowPassengerNumberService;
import cn.xscrum.common.core.controller.BaseController;
import cn.xscrum.common.core.domain.AjaxResult;
import cn.xscrum.common.utils.poi.ExcelUtil;
import cn.xscrum.common.core.page.TableDataInfo;

/**
 * 线网客流量Controller
 * 
 * @author xscrum
 * @date 2020-11-25
 */
@Controller
@RequestMapping("/demo/number")
public class FlowPassengerNumberController extends BaseController
{
    private String prefix = "demo/number";

    @Autowired
    private IFlowPassengerNumberService flowPassengerNumberService;

    @RequiresPermissions("demo:number:view")
    @GetMapping()
    public String number()
    {
        return prefix + "/number";
    }

    /**
	 * 查询线网客流量列表
     */
    @RequiresPermissions("demo:number:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FlowPassengerNumber flowPassengerNumber)
    {
        startPage();
        List<FlowPassengerNumber> list = flowPassengerNumberService.selectFlowPassengerNumberList(flowPassengerNumber);
        return getDataTable(list);
    }

    /**
	 * 导出线网客流量列表
     */
    @RequiresPermissions("demo:number:export")
    @Log(title = "线网客流量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FlowPassengerNumber flowPassengerNumber)
    {
        List<FlowPassengerNumber> list = flowPassengerNumberService.selectFlowPassengerNumberList(flowPassengerNumber);
        ExcelUtil<FlowPassengerNumber> util = new ExcelUtil<FlowPassengerNumber>(FlowPassengerNumber.class);
        return util.exportExcel(list, "number");
    }

    /**
	 * 新增线网客流量
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
	 * 新增保存线网客流量
     */
    @RequiresPermissions("demo:number:add")
    @Log(title = "线网客流量", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FlowPassengerNumber flowPassengerNumber)
    {
        return toAjax(flowPassengerNumberService.insertFlowPassengerNumber(flowPassengerNumber));
    }

    /**
	 * 修改线网客流量
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        FlowPassengerNumber flowPassengerNumber = flowPassengerNumberService.selectFlowPassengerNumberById(id);
        mmap.put("flowPassengerNumber", flowPassengerNumber);
        return prefix + "/edit";
    }

    /**
	 * 修改保存线网客流量
     */
    @RequiresPermissions("demo:number:edit")
    @Log(title = "线网客流量", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FlowPassengerNumber flowPassengerNumber)
    {
        return toAjax(flowPassengerNumberService.updateFlowPassengerNumber(flowPassengerNumber));
    }

    /**
	 * 删除线网客流量
     */
    @RequiresPermissions("demo:number:remove")
    @Log(title = "线网客流量", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(flowPassengerNumberService.deleteFlowPassengerNumberByIds(ids));
    }
}
